package com.cainaer.product.api.factory;


import com.cainaer.product.api.RemoteProductService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import feign.hystrix.FallbackFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * 用户服务降级处理
 * 
 * @author cainaer
 */
@Component
public class RemoteProductFallbackFactory implements FallbackFactory<RemoteProductService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteProductFallbackFactory.class);

    @Override
    public RemoteProductService create(Throwable throwable)
    {
        log.error("评论服务调用失败:{}", throwable.getMessage());
        return new RemoteProductService()
        {
            /**
             * 通过商商品ID查询这个这个商品的平均评价级别
             *
             * @param productId 商品ID
             * @return
             */
            @Override
            public Integer selectCommentAvgLevelByProductId(Long productId) {
                return null;
            }
        };
    }
}
